package vn.sms.lazylove;

import vn.sms.lazylove.database.DataStore;
import vn.sms.lazylove.object.SendSms;
import vn.sms.lazylove.object.Sms;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.Window;
import android.widget.ProgressBar;

public class WelcomeActivity extends Activity {

	private Context mContext;
	DataStore mDatastStore;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_welcome);
		mContext = this;
		DataStore.init(mContext);
		mDatastStore = DataStore.getInstance();
		final String[] sms_patent = new String[] {
				getString(R.string.txt_sms_1), getString(R.string.txt_sms_2),
				getString(R.string.txt_sms_3), getString(R.string.txt_sms_4),
				getString(R.string.txt_sms_5) };

		new Thread() {

			public void run() {
				try {
					synchronized (this) {
						Thread.sleep(3000);
						if (mDatastStore.getListSMSPatent().size() < 1) {
							for (int i = 0; i < sms_patent.length; i++) {
								Sms sms = new Sms(1, sms_patent[i]);
								mDatastStore.addSMSPatent(sms);
							}
						}
					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				finish();
				Intent myIntent = new Intent(getApplicationContext(),
						MainActivity.class);
				myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(myIntent);
				//stop();
			};
		}.start();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
